package com.cai.seckill.controller;

import com.cai.seckill.common.vo.LoginVo;
import com.cai.seckill.common.vo.RespBean;
import com.cai.seckill.service.UserService;
import com.cai.seckill.util.MD5Util;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

/**
 * @BelongsProject secKill
 * @Package com.cai.seckill.controller
 * @Author Uli1024
 * @CreaterTime 2022/8/4 19:37
 */
@Controller
@RequestMapping("/login")
@Slf4j
public class LoginController {

    @Autowired
    private UserService userService;

    @PostMapping("/doLogin")
    @ResponseBody
    public RespBean login(@Valid LoginVo loginVo, HttpServletRequest request, HttpServletResponse response) {
        return userService.doLogin(loginVo, request, response);
    }

    @GetMapping("/toLogin")
    public String toLogin() {
        return "login";
    }
}
